<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>相控阵雷达范围 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,bootstrap-checkbox,bootstrap-slider,layer,haoutil,turf,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <div class="infoview">
      <div>
        图层状态：
        <div class="checkbox checkbox-primary checkbox-inline">
          <input id="chkShow" class="styled" type="checkbox" checked />
          <label for="chkShow"> 显示隐藏 </label>
        </div>
        <!-- <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkPopup" class="styled" type="checkbox" checked>
        <label for="chkPopup">
          Popup绑定
        </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkTooltip" class="styled" type="checkbox">
        <label for="chkTooltip">
          Tooltip绑定
        </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkContextMenu" class="styled" type="checkbox" checked>
        <label for="chkContextMenu">
          右键菜单绑定
        </label>
      </div> -->
      </div>
      <div>
        数据维护：
        <input id="btnStartDraw" type="button" class="btn btn-primary" value="图上标绘" title="在图上绘制新增一个矢量数据" />

        <!-- <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkHasEdit" class="styled" type="checkbox">
        <label for="chkHasEdit">
          是否编辑
        </label>
      </div> -->
      </div>
      <div>
        数据管理：
        <input id="btnClear" type="button" class="btn btn-danger" value="清除" />
        <input id="btnExpFile" type="button" class="btn btn-primary" value="保存GeoJSON" title="保存为GeoJSON文件" />
        <input id="btnImpFile" type="button" class="btn btn-primary" value="打开GeoJSON" title="打开之前保存的GeoJSON文件" />

        <input id="input_draw_file" type="file" accept=".json,.geojson" style="display: none" />
      </div>
    </div>

    <!-- 属性面板 -->
    <div class="infoview" style="left: auto; right: 10px">
      <table class="mars-table">
        <tr>
          <td class="nametd">半径（米）</td>
          <td>
            <input id="model_radius" type="number" class="form-control" min="1" max="999999999" step="1.0" value="100000" title="半径" />
          </td>
        </tr>
        <tr>
          <td class="nametd">方向（heading）</td>
          <td>
            <input id="model_heading" type="text" title="方向" />
          </td>
        </tr>
        <tr>
          <td class="nametd">仰角（pitch）</td>
          <td>
            <input id="model_pitch" type="text" title="倾角pitch" />
          </td>
        </tr>
        <tr>
          <td class="nametd">左右（roll）</td>
          <td>
            <input id="model_roll" type="text" title="滚动角roll" />
          </td>
        </tr>

        <tr>
          <td class="nametd">上下夹角(X轴)</td>
          <td>
            <input id="model_angle1" type="text" />
          </td>
        </tr>
        <tr>
          <td class="nametd">左右夹角(Y轴)</td>
          <td>
            <input id="model_angle2" type="text" />
          </td>
        </tr>
        <tr>
          <td class="nametd">扫描面</td>
          <td>
            <div class="checkbox checkbox-primary checkbox-inline">
              <input id="chkShowScanPlane" class="styled" type="checkbox" checked />
              <label for="chkShowScanPlane"> 是否显示 </label>
            </div>
          </td>
        </tr>
      </table>
    </div>

    <!-- 切换视角到模型或地形（山区）的快捷按钮 -->
    <script type="text/javascript" src="js/center_terrain_3dtiles.js"></script>

    <!-- 图层管理相关处理js -->
    <script type="text/javascript" src="./js/graphicManager.js"></script>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      var map;

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            fxaa: true,
            center: { lat: 30.834006, lng: 118.779512, alt: 306743, heading: 313, pitch: -58 },
            cameraController: {
              constrainedAxis: false,
            },
          },
          control: {
            sceneModePicker: false,
          },
        });

        //创建三维地球场景
        map = new mars3d.Map("mars3dContainer", mapOptions);

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer();
        map.addLayer(graphicLayer);

        //图层管理的相关处理，代码在\js\graphicManager.js
        initLayerManager(graphicLayer);

        $("#btnStartDraw").click(function () {
          //参数
          var heading = Number($("#model_heading").val());
          var pitch = Number($("#model_pitch").val());
          var roll = Number($("#model_roll").val());
          var radius = Number($("#model_radius").val());
          var xHalfAngle = Number($("#model_angle1").val());
          var yHalfAngle = Number($("#model_angle2").val());
          var showScanPlane = $("#chkShowScanPlane").is(":checked");

          //开始绘制
          graphicLayer.startDraw({
            type: "rectangularSensor",
            style: {
              heading: heading,
              pitch: pitch,
              roll: roll,

              radius: radius, //传感器的半径
              xHalfAngleDegree: xHalfAngle, //传感器水平半角
              yHalfAngleDegree: yHalfAngle, //传感器垂直半角

              color: "#00ffff",
              opacity: 0.4,
              lineColor: "#ffffff", //线的颜色

              showScanPlane: true, //是否显示扫描面
              scanPlaneColor: "#00ffff",
              scanPlaneOpacity: 0.9,
              scanPlaneMode: "vertical", // 扫描面模式 垂直vertical/水平horizontal
              scanPlaneRate: 3, //扫描速率,
              depthTest: true,
            },
          });
        });

        //加一些演示数据
        addGraphic_01(graphicLayer);
      }

      function addGraphic_01(graphicLayer) {
        //===========绑定一些事件更新属性================
        //先设置滑动轨，才能获取到值
        $("#model_heading")
          .slider({ min: 0, max: 360, step: 0.01, value: 90 })
          .on("change", (e) => {
            if (e && e.value) {
              rectangularSensor.heading = e.value.newValue;
            }
          });
        $("#model_pitch")
          .slider({ min: 0, max: 360, step: 0.01, value: 0 })
          .on("change", (e) => {
            if (e && e.value) {
              rectangularSensor.pitch = e.value.newValue;
            }
          });
        $("#model_roll")
          .slider({ min: 0, max: 360, step: 0.01, value: 0 })
          .on("change", (e) => {
            if (e && e.value) {
              rectangularSensor.roll = e.value.newValue;
            }
          });

        $("#model_radius").change(function () {
          rectangularSensor.radius = Number($(this).val());
        });

        $("#model_angle1")
          .slider({ min: 0, max: 89, step: 0.01, value: 50 })
          .on("change", (e) => {
            if (e && e.value) {
              //传感器水平半角
              if (e && e.value) {
                rectangularSensor.style = { xHalfAngleDegree: e.value.newValue };
              }
            }
          });
        $("#model_angle2")
          .slider({ min: 0, max: 89, step: 0.01, value: 50 })
          .on("change", (e) => {
            if (e && e.value) {
              //传感器垂直半角
              if (e && e.value) {
                rectangularSensor.style = { yHalfAngleDegree: e.value.newValue };
              }
            }
          });

        $("#chkShowScanPlane").change(function () {
          var showScanPlane = $("#chkShowScanPlane").is(":checked");
          rectangularSensor.style = { showScanPlane: showScanPlane }; //是否显示扫描面
        });

        //===========参数================
        var heading = Number($("#model_heading").val());
        var pitch = Number($("#model_pitch").val());
        var roll = Number($("#model_roll").val());
        var radius = Number($("#model_radius").val());
        var xHalfAngle = Number($("#model_angle1").val());
        var yHalfAngle = Number($("#model_angle2").val());
        var showScanPlane = $("#chkShowScanPlane").is(":checked");
        var value = $("#model_heading").slider("getValue");

        var rectangularSensor = new mars3d.graphic.RectangularSensor({
          position: [117.218875, 31.817812, 138],
          style: {
            heading: heading,
            pitch: pitch,
            roll: roll,

            radius: radius, //传感器的半径
            xHalfAngleDegree: xHalfAngle, //传感器水平半角
            yHalfAngleDegree: yHalfAngle, //传感器垂直半角

            color: "#00ffff",
            opacity: 0.4,
            lineColor: "#ffffff", //线的颜色

            showScanPlane: true, //是否显示扫描面
            scanPlaneColor: "#00ffff",
            scanPlaneOpacity: 0.9,
            scanPlaneMode: "vertical", // 扫描面模式 垂直vertical/水平horizontal
            scanPlaneRate: 3, //扫描速率,
            depthTest: true,
          },
        });

        graphicLayer.addGraphic(rectangularSensor);
      }
    </script>
  </body>
</html>
